<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>index</title>
  <style>
    #canvas {

      background-color: #eee;
    }
  </style>
</head>

<body>
  <h2>canvas</h2>
  <canvas id="canvas" width="800px" height="300px">

  </canvas>
  <svg style="background-color:#eee;height: 400px;display: block;width: 800px;">
    <line x1='50' y1="50" x2="100" y2="50" stroke='#666' />
    <polyline points="50 50 100 50 50 100 100 100" fill-opacity="0" stroke="#666" />
  </svg>
  <script>




    const canvas = document.getElementById('canvas')
    const context = canvas.getContext('2d')
    context.strokeStyle = '#666'
    context.moveTo(50, 50)
    context.lineTo(100, 50)
    context.lineTo(50, 100)
    context.lineTo(100, 100)
    context.stroke()
    context.moveTo(125, 50)
    context.lineTo(125, 100)
    context.moveTo(125, 75)
    context.lineTo(160, 75)
    context.lineTo(160, 100)
    context.lineTo(160, 50)
    context.stroke()

    context.fillStyle = 'red'
    context.fillRect(190, 50, 50, 50)
    context.strokeRect(190, 50, 50, 50)

    context.beginPath();
    context.arc(290, 75, 25, 0, Math.PI, false)
    context.moveTo(265, 75)
    context.lineTo(265, 50)
    context.moveTo(315, 75)
    context.lineTo(315, 50)
    context.stroke()
    context.closePath()

    // 清空画布
    // context.clearRect(0, 0, 800, 400)

    // 绘制文字
    context.beginPath();
    context.font = '40px'
    context.fillText('国', 50, 200, 10)
    context.stroke()
  </script>
</body>

</html>